using System.Xml;

namespace Kotonoha.Server.Xml {
    public class ContentHandler : ElementHandler {
        private readonly ReaderAction action;
        private ContentHandler(string name) : base(name) {}
        public ContentHandler(string name, StringContentAction action) : this(name) {
            this.action = (r => action(r.ReadString()));
        }

        public ContentHandler(string name, IntContentAction action) : this(name) {
            this.action = (r => action(r.ReadContentAsInt()));
        }

        protected override void readBody(XmlReader reader) {
            action(reader);
        }
    }
}